.\" Copyright (c) 2002, Sun Microsystems, Inc.
.\" Copyright (c) 2017, Joyent, Inc.
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.Dd October 23, 2017
.Dt HDIO 4I
.Os
.Sh NAME
.Nm hdio
.Nd SMD and IPI disk control operations
.Sh SYNOPSIS
.In sys/hdio.h
.Sh DESCRIPTION
Note \(em the SMC and IPI drivers have been discontinued.
.Xr dkio 4I
is now the preferred method for retrieving disk information.
.Pp
The SMD and IPI disk drivers supplied with this release support a set of
.Xr ioctl 2
requests for diagnostics and bad sector information.
Basic to these
.Xr ioctl 2
requests are the definitions in
.In sys/hdio.h .
.Sh IOCTLS
.Bl -tag -width HDKIOCGTYPE
.It Dv HDKIOCGTYPE
The argument is a pointer to a
.Vt hdk_type
structure (described below).
This
.Xr ioctl 2
gets specific information from the hard disk.
.It Dv HDKIOCSTYPE
The argument is a pointer to a
.Vt hdk_type
structure (described below).
This
.Xr ioctl 2
sets specific information about the hard disk.
.El
.Bd -literal -offset 2n
/*
 * Used for drive info
 */
struct hdk_type {
	ushort_t  hdkt_hsect;    /* hard sector count (read only) */
	ushort_t  hdkt_promrev;  /* prom revision (read only) */
	uchar_t   hdkt_drtype;   /* drive type (ctlr specific) */
	uchar_t   hdkt_drstat;   /* drive status (ctlr specific, ro) */
};
.Ed
.Bl -tag -width HDKIOCGBAD
.It Dv HDKIOCGBAD
The argument is a pointer to a
.Vt hdk_badmap
structure (described below).
This
.Xr ioctl 2
is used to get the bad sector map from the disk.
.It Dv HDKIOCSBAD
The argument is a pointer to a
.Vt hdk_badmap
structure (described below).
This
.Xr ioctl 2
is used to set the bad sector map on the disk.
.El
.Bd -literal -offset 2n
/*
 * Used for bad sector map
 */
struct hdk_badmap {
	caddr_t	hdkb_bufaddr;	/* address of user's map buffer */
};
.Ed
.Bl -tag -width HDKIOCGDIAG
.It Dv HDKIOCGDIAG
The argument is a pointer to a
.Vt hdk_diag
structure (described below).
This
.Xr ioctl 2
gets the most recent command that failed along with the
sector and error number from the hard disk.
.El
.Bd -literal -offset 2n
/*
 * Used for disk diagnostics
 */
struct hdk_diag {
	ushort_t hdkd_errcmd; /* most recent command in error */
	daddr_t	hdkd_errsect; /* most recent sector in error */
	uchar_t	hdkd_errno;   /* most recent error number */
	uchar_t	hdkd_severe;  /* severity of most recent error */
};
.Ed
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr dkio 4I
